package com.mbf.crm.common;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;

/**
 * 用户vo
 * 
 * @author 晏鼠 张劲松
 *
 */
public class ImUser {

	private long uid;

	private String realName;

	public ImUser() {
	}

	public long getUid() {
		return uid;
	}

	public void setUid(long uid) {
		this.uid = uid;
	}

	public String getRealName() {
		return realName;
	}

	public void setRealName(String realName) {
		this.realName = realName;
	}

	public ImUser(long uid, String realName) {
		super();
		this.uid = uid;
		this.realName = realName;
	}

	// HashCodeBuilder、EqualsBuilder都是辅助实现hashcode()和equal()方法的工具类

	@Override
	public int hashCode() {
		return new HashCodeBuilder(17, 37).append(uid).append(realName)
				.toHashCode();
	}

	/**
	 * 官方例子：
	 * public boolean equals(Object obj) {
	   if (obj == null) { return false; }
	   if (obj == this) { return true; }
	   if (obj.getClass() != getClass()) {
	     return false;
	   }
	   MyClass rhs = (MyClass) obj;
	   return new EqualsBuilder()
	                 .appendSuper(super.equals(obj))
	                 .append(field1, rhs.field1)
	                 .append(field2, rhs.field2)
	                 .append(field3, rhs.field3)
	                 .isEquals();
	  }

	 */
	@Override
	public boolean equals(Object o) {
		if (this == o)
			return true;
		if (o == null || getClass() != o.getClass())
			return false;
		ImUser user = (ImUser) o;
		return new EqualsBuilder().append(uid, user.uid)
				.append(realName, user.realName).isEquals();
	}

}
